<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 1. call
    // const liu = {
    //   name:  '刘德华',
    //   sing(song1, song2, song3){
    //     console.log(`${this.name}会唱${song1}, ${song2}, ${song3}`)
    //   }
    // }
    // // liu.sing('中国人', '忘情水', '爱我一万年')

    // const tou = {
    //   name: '小偷'
    // }
    // liu.sing.call(tou, '恭喜发财1', '恭喜发财2', '恭喜发财3')

    // 2. apply
    // const liu = {
    //   name: '刘德华',
    //   sing(song1, song2, song3) {
    //     console.log(`${this.name}会唱${song1}, ${song2}, ${song3}`)
    //   }
    // }
    // // liu.sing('中国人', '忘情水', '爱我一万年')

    // const tou = {
    //   name: '小偷'
    // }
    // liu.sing.apply(tou, ['恭喜发财1', '恭喜发财2', '恭喜发财3'])

    // 3. bind
    const liu = {
      name: '刘德华',
      sing(song1, song2, song3) {
        console.log(`${this.name}会唱${song1}, ${song2}, ${song3}`)
      }
    }
    // liu.sing('中国人', '忘情水', '爱我一万年')

    const tou = {
      name: '小偷'
    }
    const fn =  liu.sing.bind(tou)
    fn('中国人', '忘情水', '爱我一万年')
  </script>
</body>
</html>